package com.my.jli.dao;

import com.my.jli.entity.Student;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Set;

/**
 * @ClassName StudentDao
 * @Description
 * @Author MaYu
 * @Date 2022/1/20 19:03
 * @Version 1.0
 **/
public interface StudentRepository extends JpaRepository<Student, Integer> {
    //根据学号和密码查找学生
    List<Student> findByNumAndPwd(String sName, String sPwd);

    Page<Student> findByTid(Integer tid, Pageable pageable);

    //获得所有年级
    @Query("select grade from tb_student ")
    Set<String> findGrade();

    //获得所有班级
    @Query("select clazz from tb_student ")
    Set<String> findClazz();

    //根据学号获取学生
    Student findByNum(String num);

    //根据学号和教师id获取学生
    Student findByNumAndTid(String num, Integer tid);

    List<Student> findByTid(Integer tid);
}
